package com.yida.gwj.expend.outside.config;

import cn.hutool.core.util.IdUtil;
import com.yida.gwj.common.domain.mq.MqSendRequest;
import com.yida.gwj.common.enums.MqDelayLevelEnum;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 维修基金业务配置
 *
 * @author liangp
 * @date 2023/02/17
 */
@Configuration
public class MaintenanceFundsBusinessConfiguration {

    public static String maintenanceFundsBusinessTopic;

    @Value("${gwj.expend.topic}")
    public void setMaintenanceFundsBusinessTopic(String setMaintenanceFundsBusinessTopic) {
        maintenanceFundsBusinessTopic = setMaintenanceFundsBusinessTopic;
    }

    public static String maintenanceFundsBusinessAppropriateTopic;

    @Value("${gwj.expend-appropriate.topic}")
    public void setMaintenanceFundsBusinessAppropriateTopic(String setMaintenanceFundsBusinessAppropriateTopic) {
        maintenanceFundsBusinessAppropriateTopic = setMaintenanceFundsBusinessAppropriateTopic;
    }

    public static String maintenanceFundsBusinessUrgentTopic;

    @Value("${gwj.expend-urgent.topic}")
    public void setMaintenanceFundsBusinessUrgentTopic(String setMaintenanceFundsBusinessUrgentTopic) {
        maintenanceFundsBusinessUrgentTopic = setMaintenanceFundsBusinessUrgentTopic;
    }

    public static String maintenanceFundsBusinessUrgentAppropriateTopic;

    @Value("${gwj.expend-urgent-appropriate.topic}")
    public void setMaintenanceFundsBusinessUrgentAppropriateTopic(String setMaintenanceFundsBusinessUrgentAppropriateTopic) {
        maintenanceFundsBusinessUrgentAppropriateTopic = setMaintenanceFundsBusinessUrgentAppropriateTopic;
    }

    @RefreshScope
    @Bean
    @ConfigurationProperties(prefix = "gwj.expend.tag")
    public MaintenanceFundsBusinessTagProperties tagProperties() {
        return new MaintenanceFundsBusinessTagProperties();
    }

    @RefreshScope
    @Bean
    @ConfigurationProperties(prefix = "gwj.expend-appropriate.tag")
    public MaintenanceFundsBusinessAppropriateTagProperties appropriateTagProperties() {
        return new MaintenanceFundsBusinessAppropriateTagProperties();
    }

    @RefreshScope
    @Bean
    @ConfigurationProperties(prefix = "gwj.expend-urgent.tag")
    public MaintenanceFundsBusinessUrgentTagProperties urgentTagProperties() {
        return new MaintenanceFundsBusinessUrgentTagProperties();
    }

    @RefreshScope
    @Bean
    @ConfigurationProperties(prefix = "gwj.expend-urgent-appropriate.tag")
    public MaintenanceFundsBusinessUrgentAppropriateTagProperties urgentAppropriateTagProperties() {
        return new MaintenanceFundsBusinessUrgentAppropriateTagProperties();
    }

    public static class MaintenanceFundsBusinessSendRequest extends MqSendRequest {
        public MaintenanceFundsBusinessSendRequest(String tag, MqDelayLevelEnum level) {
            super(MaintenanceFundsBusinessConfiguration.maintenanceFundsBusinessTopic, IdUtil.getSnowflakeNextIdStr(), tag, level == null ? MqDelayLevelEnum.ZERO : level);
        }
    }

    public static class MaintenanceFundsBusinessAppropriateSendRequest extends MqSendRequest {
        public MaintenanceFundsBusinessAppropriateSendRequest(String tag, MqDelayLevelEnum level) {
            super(MaintenanceFundsBusinessConfiguration.maintenanceFundsBusinessAppropriateTopic, IdUtil.getSnowflakeNextIdStr(), tag, level == null ? MqDelayLevelEnum.ZERO : level);
        }
    }

    public static class MaintenanceFundsBusinessUrgentSendRequest extends MqSendRequest {
        public MaintenanceFundsBusinessUrgentSendRequest(String tag, MqDelayLevelEnum level) {
            super(MaintenanceFundsBusinessConfiguration.maintenanceFundsBusinessUrgentTopic, IdUtil.getSnowflakeNextIdStr(), tag, level == null ? MqDelayLevelEnum.ZERO : level);
        }
    }

    public static class MaintenanceFundsBusinessUrgentAppropriateSendRequest extends MqSendRequest {
        public MaintenanceFundsBusinessUrgentAppropriateSendRequest(String tag, MqDelayLevelEnum level) {
            super(MaintenanceFundsBusinessConfiguration.maintenanceFundsBusinessUrgentAppropriateTopic, IdUtil.getSnowflakeNextIdStr(), tag, level == null ? MqDelayLevelEnum.ZERO : level);
        }
    }

}

